import 'package:flutter/material.dart';

/// 标准跳转
class StandSkipDemo extends StatefulWidget {
  const StandSkipDemo({Key? key}) : super(key: key);

  @override
  _StandSkipDemoState createState() => _StandSkipDemoState();
}

class _StandSkipDemoState extends State<StandSkipDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("标准跳转"),
        ),
        body: Container(
          padding: EdgeInsets.all(16),
          child: Column(
            children: [
              Text("测试push,pop"),
              SizedBox(
                height: 15,
              ),
              SizedBox(
                width: double.infinity,
                child: RaisedButton(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(8)),
                  child: Text("资讯"),
                  onPressed: () {
                    Navigator.of(context)
                        .push(MaterialPageRoute(builder: (context) {
                      return TestPage("资讯");
                    }));
                  },
                ),
              ),
              SizedBox(
                height: 15,
              ),
              SizedBox(
                width: double.infinity,
                child: RaisedButton(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(8)),
                  child: Text("设置"),
                  onPressed: () {
                    Navigator.of(context)
                        .push(MaterialPageRoute(builder: (context) {
                      return TestPage("设置");
                    }));
                  },
                ),
              )
            ],
          ),
        ));
  }
}

class TestPage extends StatelessWidget {
  final String title;

  const TestPage(this.title, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Navigator.pop(context);
        },
        child: Icon(Icons.arrow_back),
      ),
    );
  }
}
